package leetcode14

// 逐个字符匹配
func longestCommonPrefix(strs []string) string {
	var res string
	if len(strs) == 0 {
		return res
	}
	res = strs[0]
	if len(strs) == 1 {
		return res
	}

	for i := 0; i < len(res); i++ {
		for _, str := range strs {
			if i >= len(str) || str[i] != res[i] {
				return res[:i]
			}
		}
	}
	return res
}
